/*
 * ODO: Real-Time In-Memory ORM/DBMS Grid software
 * Copyright (c) 2008, Michael Oksenenko
 * All rights reserved.
 */
#ifndef SYSLOG_FACTORY_HPP
#define SYSLOG_FACTORY_HPP

#include "OsConfig.hpp"

#include "OsComponentFactoryIF.hpp"
#include "SyslogIF.hpp"
#include "SyslogStub.hpp"
#include "SyslogLinux.hpp"
#include "SyslogVista.hpp"

#include <memory>

namespace odo {

template<unsigned OS>
class SyslogFactory : public OsComponentFactoryIF<SyslogIF> {

public: // iface

	virtual std::auto_ptr<SyslogIF> getComponent() = 0;

public: // factory

	virtual ~SyslogFactory() { /* void */ }

};

//============================================================================
#if ODO_OS_LINUX == ODO_CHOSEN_OS
//----------------------------------------------------------------------------
template<>
class SyslogFactory<ODO_OS_LINUX> : public OsComponentFactoryIF<SyslogIF> {

public: // iface

	virtual std::auto_ptr<SyslogIF> getComponent() {
		return std::auto_ptr<SyslogIF>(new SyslogLinux());
	}

public: // factory

	virtual ~SyslogFactory() { /* void */ }
	SyslogFactory() { /* void */ }

};

#endif /* ODO_OS_LINUX */
//============================================================================
#if ODO_OS_VISTA == ODO_CHOSEN_OS
//----------------------------------------------------------------------------
template<>
class SyslogFactory<ODO_OS_VISTA> : public OsComponentFactoryIF<SyslogIF> {

public: // iface

	virtual std::auto_ptr<SyslogIF> getComponent() {
		std::auto_ptr<SyslogVista> syslogVista(new SyslogVista());
		syslogVista->open(static_cast<const wchar_t*>(SYSLOG_NAME));
		if (syslogVista->isClosed()) {
			return std::auto_ptr<SyslogIF>(new SyslogStub());
		}
		return syslogVista;
	}

public: // factory

	virtual ~SyslogFactory() { /* void */ }
	SyslogFactory() { /* void */ }

};
//----------------------------------------------------------------------------
#endif /* ODO_OS_VISTA */
//============================================================================

}

#endif /* SYSLOG_FACTORY_HPP */
